// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App'
import router from './router'
import './assets/iconfont/iconfont.css'
import addTrainStep1 from '@/pages/home/children/addTrainStep1/addTrainStep1'
import addTrainStep2 from '@/pages/home/children/addTrainStep2/addTrainStep2'
import trainDetail from '@/pages/home/children/trainDetail/trainDetail'
import checkTrain from '@/pages/home/children/checkTrain/checkTrain'
import VueAMap from 'vue-amap'
import IP from '../src/pages/IP/IP'
import axios from 'axios'
import Qs from 'qs'
import VueAxios from 'vue-axios'
import identify from '@/pages/identify/identify'
Vue.use(identify);
axios.interceptors.response.use(
  function (response) {

  return response;
}, 
 error =>{
  console.log(error.response.status)
  if(error.response.status===405){
    console.log(this.$router);

    router.push({
      path:'/'
    });
    alert('请先登录');
  }
  //return Promise.reject(error);
});
var axios_instance = axios.create({
  baseURL:'http://47.101.180.43:8075', //自行修改url,
  transformRequest: [function (data) {
  data = Qs.stringify(data);
  return data;
  }],
  headers:{'Content-Type':'application/x-www-form-urlencoded',
  'Access-Control-Allow-Credentials': 'true'}
  })

Vue.use(VueAxios, axios_instance)
/**axios不是vue插件，所以需要这样配置，可以通过this.$http代替axios，而不用每个.vue里面再去import */
Vue.prototype.$ajax=axios
/**运行跨域请求*/
axios.defaults.withCredentials=true

Vue.prototype.IP=IP.IP
Vue.use(VueAMap);
Vue.use(ElementUI);
Vue.config.productionTip = false
Vue.use(addTrainStep1)
Vue.use(addTrainStep2)
Vue.use(trainDetail)
Vue.use(checkTrain)
VueAMap.initAMapApiLoader({
  key: 'b309c21e07d89f391fccfa363c7299e3',
  /**插件集合,这里不仅要全局引入，使用时还要给单个地图配置插件*/
  /**
   * AMap.Scale:显示比例尺的插件
   * AMap.OverView:鹰眼插件
   * AMap.ToolBar：工具尺插件
   * AMap.MapType：地图类型切换插件，用来切换固定的几个常用图层 
   * AMap.Geolocation：精确定位插件 */
	plugin: ['AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType','AMap.Geolocation','MarkerClusterer','AMap.Geocoder'],
  /**默认高德 sdk 版本为 1.4.4*/
  v: '1.4.4',
  /**ui库版本，不配置不加载*/
  uiVersion: '1.0.11' // 版本号
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
